//店铺页面函数控制页面样式变化
//页面分左右两边用transform控制滚动
/*var transformScrolls = function (leftId, rightId, shop) {
    this.leftId = leftId;
    this.rightId = rightId;
    this.shop = shop;
    this.init();
    this.messageRun();
    this.bind();
};
transformScrolls.prototype = {
    init: function () {
        var self = this;
        var storeBody = document.querySelector('.store_body');
        var storeBodyHeight = $(window).height() - 125;
        storeBody.style.height = storeBodyHeight + 45 + "px";
        this.hei = storeBodyHeight;//读取屏幕高度除去顶部栏高度
        this.scrollLeftHeight = 0;
        this.scrollStatus = true;
        this.modelHtmlHeight = document.getElementById('modelHtml').offsetHeight;
        this.modelHtmlId = 'modelHtml';
        this.LeftLi = $("#" + this.leftId).find("li");
        this.timeCssContor = null;
        if (document.querySelector('.store_tag_choose') == null) {
            this.LeftLi[0].setAttribute('class', 'store_tag_choose');
            this.lastClick = this.LeftLi[0];
        }
        $("#storeLeft").css({"height": (this.hei) + "px"});
        $("#storeRight").css({"height": (this.hei) + "px"});//设置父类框高度
        //判断是否是具体商店页面，如果是具体商店页面要减去底部悬浮购物车的高度
        this.scrollLeftHeight = $("#" + this.leftId).height() - this.hei;
        this.leftTouchObj = {
            startY: 0,
            scrollY: 0
        };
        this.rightTouchObj = {
            startY: 0,
            scrollY: 0
        };//初始化开始的位置和单位时间滚动距离
        for (var i = 0; i < this.LeftLi.length; i++) {
            this.LeftLi[i].onclick = function () {
                var id = this.id;
                var leftLi = document.getElementById(id);
                clearInterval(self.timeCssContor);
                var rightLiId = "goodList" + id.substring(8);
                self.lastClick.removeAttribute('class', 'store_tag_choose');
                leftLi.setAttribute('class', 'store_tag_choose');
                var rightLi = document.getElementById(rightLiId);
                var transY = self.getModelY(self.modelHtmlId) + self.modelHtmlHeight - rightLi.offsetTop;
                self.scrollRightHeight = $("#" + self.rightId).height() - self.hei;
                if (self.scrollRightHeight > 0) {
                    if (transY < -self.scrollRightHeight) {
                        transY = -self.scrollRightHeight
                    }
                    $("#" + self.rightId).css({
                        "transform": "translateY(" + transY + "px)",
                        "-webkit-transform": "transition(" + transY + "px)",
                        "transition-duration": "0ms"
                    })
                }
                self.lastClick = leftLi;
            }
        }
    },
    bind: function () {
        var self = this;
        $("#" + self.leftId).on("touchstart", function () {
            clearInterval(self.timeCssContor);
            var translateY = self.getY(self.leftId);
            $("#" + self.leftId).css({
                "transform": "translateY(" + translateY + "px)",
                "-webkit-transform": "translateY(" + translateY + "px)",
                "transition-timing-function": "cubic-bezier(0.1, 0.57, 0.57, 1)",
                "transition-duration": "0ms"
            });
            self.leftTouchObj.startY = event.touches[0].clientY;  // 纵坐标
            self.leftTouchObj.scrollY = 0;
            var modelEndTranY = self.getModelY(self.modelHtmlId);
            if (modelEndTranY > -120) {
                self.scrollStatus = false;
            } else {
                self.scrollStatus = true;
            }
        })
        $("#" + self.leftId).on("touchmove", function () {
            //可滚动区域大于零执行滚动函数
            event.stopPropagation();
            event.preventDefault();
            var touches = event.touches[0];
            var endY = touches.clientY - self.leftTouchObj.startY;
            if (endY > 0) {
                self.scrollStatus = true;
            }
            var modelEndTranY = self.getModelY(self.modelHtmlId);
            var modelEndY = endY + modelEndTranY;
            var endTranY = self.getY(self.leftId);
            var allEndY = endY + endTranY;
            var modelCss;
            var modelHtmlHeight = -self.modelHtmlHeight + 80;
            /!*if (modelEndTranY != 0) {
                event.preventDefault();
            }*!/
            if (endY < 0) {
                if (modelEndTranY > modelHtmlHeight) {
                    if (modelEndY < modelHtmlHeight) {
                        modelEndY = modelHtmlHeight;
                    }
                    modelCss = {
                        "margin-top": modelEndY + "px",
                    };
                    $("#" + self.modelHtmlId).css(modelCss);
                    self.setTopOpacity(modelEndY, modelHtmlHeight);
                } else {
                    if (self.scrollLeftHeight > 0) {
                        if (allEndY > 0) {
                            allEndY = 0
                        }
                        else {
                            if (allEndY < (self.scrollLeftHeight * -1)) {
                                allEndY = (self.scrollLeftHeight * -1);
                            }
                        }
                        $(this).css({
                            "transform": "translateY(" + allEndY + "px)",
                            "-webkit-transform": "transition(" + allEndY + "px)"
                        });
                    }
                }
            } else {
                if (endTranY == 0) {
                    if (modelEndY > 0) {
                        modelEndY = 0;
                    }
                    modelCss = {
                        "margin-top": modelEndY + "px",
                    };
                    $("#" + self.modelHtmlId).css(modelCss);
                    self.setTopOpacity(modelEndY, modelHtmlHeight);
                } else {
                    if (self.scrollLeftHeight > 0) {
                        if (allEndY > 0) {
                            allEndY = 0
                        }
                        else {
                            if (allEndY < (self.scrollLeftHeight * -1)) {
                                allEndY = (self.scrollLeftHeight * -1);
                            }
                        }
                        $(this).css({
                            "transform": "translateY(" + allEndY + "px)",
                            "-webkit-transform": "transition(" + allEndY + "px)"
                        });
                    }
                }
            }
            self.leftTouchObj.scrollY = touches.clientY - self.leftTouchObj.startY;
            self.leftTouchObj.startY = touches.clientY;//重置开始滚动的位置
        });
        $("#" + self.leftId).on("touchend", function (e) {
            if (self.scrollStatus == false) {
                return;
            }
            if (self.scrollLeftHeight > 0) {
                var modelEndTranY = self.getModelY(self.modelHtmlId);
                var endTranY = self.getY(self.leftId);
                if (self.leftTouchObj.scrollY > 0) {
                    if (endTranY != 0) {
                        self.touchScroll(self.leftTouchObj.scrollY, self.leftId, self.scrollLeftHeight);
                    }
                } else {
                    if (modelEndTranY == (-self.modelHtmlHeight + 80)) {
                        self.touchScroll(self.leftTouchObj.scrollY, self.leftId, self.scrollLeftHeight);
                    }
                }
            }
            //结束之后判断单位时间移动的距离如果距离大，设置一定的滚动速度
        });
        $("#" + self.rightId).on("touchstart", function () {
            clearInterval(self.timeCssContor);
            self.setLeftLiStyle();
            var translateY = self.getY(self.rightId);
            $("#" + self.rightId).css({
                "transform": "translateY(" + translateY + "px)",
                "-webkit-transform": "translateY(" + translateY + "px)",
                "transition-timing-function": "cubic-bezier(0.1, 0.57, 0.57, 1)",
                "transition-duration": "0ms"
            });
            self.rightTouchObj.startY = event.touches[0].clientY;  // 纵坐标
            self.rightTouchObj.scrollY = 0;
            self.scrollRightHeight = $("#" + self.rightId).height() - self.hei;
            var modelEndTranY = self.getModelY(self.modelHtmlId);
            if (modelEndTranY > -120) {
                self.scrollStatus = false;
            } else {
                self.scrollStatus = true;
            }
        });
        $("#" + self.rightId).on("touchmove", function (e) {
            event.preventDefault();
            event.stopPropagation();
            var touches = event.touches[0];
            var endY = touches.clientY - self.rightTouchObj.startY;
            if (endY > 0) {
                self.scrollStatus = true;
            };
            var modelEndTranY = self.getModelY(self.modelHtmlId);
            var modelEndY = endY + modelEndTranY;
            var endTranY = self.getY(self.rightId);
            var allEndY = endY + endTranY;
            var modelCss;
            var modelHtmlHeight = -self.modelHtmlHeight + 80;
            /!*if (modelEndTranY != 0) {
                event.preventDefault();
            }*!/
            if (endY < 0) {
                if (modelEndTranY > modelHtmlHeight) {
                    if (modelEndY < modelHtmlHeight) {
                        modelEndY = modelHtmlHeight;
                    }
                    modelCss = {
                        "margin-top": modelEndY + "px",
                    };
                    $("#" + self.modelHtmlId).css(modelCss);
                    self.setTopOpacity(modelEndY, modelHtmlHeight);
                } else {
                    if (self.scrollRightHeight > 0) {
                        if (allEndY > 0) {
                            allEndY = 50
                        }
                        else {
                            if (allEndY < (self.scrollRightHeight * -1)) {
                                allEndY = (self.scrollRightHeight * -1);
                            }
                        }
                        $(this).css({
                            "transform": "translateY(" + allEndY + "px)",
                            "-webkit-transform": "transition(" + allEndY + "px)"
                        });
                    }
                }
            } else {
                if (endTranY == 0) {
                    if (modelEndY > 0) {
                        modelEndY = 0;
                    }
                    modelCss = {
                        "margin-top": modelEndY + "px",
                    };
                    $("#" + self.modelHtmlId).css(modelCss);
                    self.setTopOpacity(modelEndY, modelHtmlHeight);
                } else {
                    if (self.scrollRightHeight > 0) {
                        if (allEndY > 0) {
                            allEndY = 0
                        }
                        else {
                            if (allEndY < (self.scrollRightHeight * -1)) {
                                allEndY = (self.scrollRightHeight * -1);
                            }
                        }
                        $(this).css({
                            "transform": "translateY(" + allEndY + "px)",
                            "-webkit-transform": "transition(" + allEndY + "px)"
                        });
                    }
                }
            }
            self.setLeftLiStyle();
            self.rightTouchObj.scrollY = touches.clientY - self.rightTouchObj.startY;
            self.rightTouchObj.startY = touches.clientY;
        });
        $("#" + self.rightId).on("touchend", function (e) {
            if (self.scrollStatus == false) {
                return;
            }
            if (self.scrollRightHeight > 0) {
                var modelEndTranY = self.getModelY(self.modelHtmlId);
                var endTranY = self.getY(self.rightId);
                if (self.rightTouchObj.scrollY > 0) {
                    if (endTranY != 0) {
                        self.touchScroll(self.rightTouchObj.scrollY, self.rightId, self.scrollRightHeight);
                    }
                } else {
                    if (modelEndTranY == (-self.modelHtmlHeight + 80)) {
                        self.touchScroll(self.rightTouchObj.scrollY, self.rightId, self.scrollRightHeight);
                    }
                }
            }
        });
        $(window).resize(function () {
            setTimeout(function () {
                self.init()
            }, 100)
        });
    },
    getY: function (Id) {
        var transform = $("#" + Id).css("transform");
        if (!transform) {
            transform = $("#" + Id).css("-webkit-transform");
        }
        if (transform == "none") {
            transform = 0
        }
        else {
            if (transform == undefined) {
                clearInterval(this.timeCssContor);
            }
            transform = transform.replace("matrix(", "").replace(")", "");
            transform = transform.split(',', 6);
            transform = transform[5];
            transform = parseInt(transform, 10)
        }
        if (!transform) {
            transform = 0
        }
        return transform
    },
    getModelY: function (Id) {
        var marginTop = $("#" + Id).css("margin-top");
        if (marginTop == "none") {
            marginTop = 0
        }
        else {
            marginTop = marginTop.substring(0, marginTop.length - 2);
            marginTop = parseInt(marginTop, 10)
        }
        if (!marginTop) {
            marginTop = 0
        }
        return marginTop
    },
    touchScroll: function (scrollY, Id, scrollHeight, g) {
        var self = this;
        var absScrollY = Math.abs(scrollY);
        var speed = 0;
        if (absScrollY >= 8) {
            speed = absScrollY;
        }
        else {
            speed = 0
        }
        ;//根据单位时间位移的量来设置结束后的速度
        if (speed > 0) {
            if (scrollY < 0) {
                speed = speed * -1
            }
            //speed = Math.round(speed);
            speed = Math.round(speed);
            setTimeout(function () {
                self.touchScrollRun(speed, Id, 0, scrollHeight);
            }, 2);
        }
        else {
            var translateY = 0;
            translateY = this.getY(Id);
            //不满足条件读取当前transform的值
            self.goToEnd(translateY, Id, scrollHeight);
        }
    },
    touchScrollRun: function (speed, Id, number, scrollHeight) {
        var self = this;
        var transY;
        var translateY = 0;
        var t = Math.abs(speed * 30);
        translateY = this.getY(Id) + speed * 20;
        $("#" + Id).css({
            "transform": "translateY(" + translateY + "px)",
            "-webkit-transform": "translateY(" + translateY + "px)",
            "transition-timing-function": "cubic-bezier(0.1, 0.57, 0.57, 1)",
            "transition-duration": t + "ms"
        });
        self.timeCssContor = setInterval(function () {
            transY = self.getY(Id);
            self.setLeftLiStyle();
            if (transY <= (scrollHeight * -1)) {
                transY = (scrollHeight * -1) + (scrollHeight + translateY);
                self.goToEnd(transY, Id, scrollHeight);
                clearInterval(self.timeCssContor);
            } else if (transY > 0) {
                transY = translateY;
                self.goToEnd(transY, Id, scrollHeight);
                clearInterval(self.timeCssContor);
            } else if (transY == translateY) {
                clearInterval(self.timeCssContor);
            }
        }, 2);
    },
    goToEnd: function (translateY, Id, scrollHeight) {
        var touchedCss = null;
        var endCss = null;
        if (scrollHeight > 0) {
            if (translateY < (scrollHeight * -1)) {
                touchedCss = {
                    transform: "translateY(" + (scrollHeight * -1) + "px)",
                    "-webkit-transform": "translateY(" + (scrollHeight * -1) + "px)",
                    "transition-timing-function": "cubic-bezier(0.1, 0.57, 0.57, 1)",
                    "transition-duration": "600ms"
                };
                endCss = {
                    transform: "translateY(" + (scrollHeight * -1) + "px)",
                    "-webkit-transform": "translateY(" + (scrollHeight * -1) + "px)",
                    "transition-timing-function": "cubic-bezier(0.1, 0.57, 0.57, 1)",
                    "transition-duration": "0ms"
                }
            }
            else {
                if (translateY > 0) {
                    touchedCss = {
                        transform: "translateY(0px)",
                        "-webkit-transform": "translateY(0px)",
                        "transition-timing-function": "cubic-bezier(0.1, 0.57, 0.57, 1)",
                        "transition-duration": "600ms"
                    };
                    endCss = {
                        transform: "translateY(0px)",
                        "-webkit-transform": "translateY(0px)",
                        "transition-timing-function": "cubic-bezier(0.1, 0.57, 0.57, 1)",
                        "transition-duration": "0ms"
                    }
                }
            }
        }
        if (translateY != 0) {
            if (endCss != null && touchedCss != null) {
                $("#" + Id).css(touchedCss);
                setTimeout(function () {
                    $("#" + Id).css(endCss)
                }, 600);
            }
            return true
        }
        else {
            $("#" + Id).css({transform: "translateY(0px)"});
            $("#" + Id).css({"-webkit-transform": "translateY(0px)"});
            return false
        }
    },
    setTopOpacity: function (position, height) {
        var topHeadBac = document.getElementById('topHeadBac');
        topHeadBac.style.opacity = -position / (-height);
    },
    setLeftLiStyle: function () {
        var rightLi = $("#" + this.rightId).find('.store_mainmenu ');
        var rightLiId, rightLiTop, rightMaxTop, leftLiId, leftLi;
        var transY = this.getY(this.rightId);
        for (var i = 0; i < rightLi.length; i++) {
            rightLiTop = this.getModelY(this.modelHtmlId) + this.modelHtmlHeight - rightLi[i].offsetTop;
            rightMaxTop = this.getModelY(this.modelHtmlId) + this.modelHtmlHeight - rightLi[rightLi.length - 1].offsetTop;
            if (rightLiTop <= transY + 1) {
                rightLiId = rightLi[i].id;
                break;
            }
            if (rightLiTop >= rightMaxTop) {
                rightLiId = rightLi[i].id;
            }
        }
        if (rightLiId == undefined) {
            clearInterval(this.timeCssContor);
        }
        leftLiId = "leftList" + rightLiId.substring(8);
        if (this.lastClick.id != leftLiId) {
            leftLi = document.getElementById(leftLiId);
            this.lastClick.removeAttribute('class', 'store_tag_choose');
            leftLi.setAttribute('class', 'store_tag_choose');
            this.lastClick = leftLi;
        }
    },
    messageRun:function(){
        var self = this;
        var message = $("#message");
        if(!message){
            return;
        }
        var touche = {
            startY:0,
        };
        message.on("touchstart",function(){
            touche.startY = event.touches[0].clientY;
            var modelEndTranY = self.getModelY(self.modelHtmlId);
            if (modelEndTranY > -120) {
                self.scrollStatus = false;
            } else {
                self.scrollStatus = true;
            }
        });
        message.on("touchmove",function(){
            event.stopPropagation();
            var touches = event.touches[0];
            var endY = touches.clientY - touche.startY;
            var modelEndTranY = self.getModelY(self.modelHtmlId);
            var modelEndY = endY + modelEndTranY;
            var endTranY = self.getY(self.rightId);
            var modelCss;
            var modelHtmlHeight = -self.modelHtmlHeight + 80;
            if (endY < 0) {
                if (modelEndTranY > modelHtmlHeight) {
                    event.preventDefault();
                }else{
                    touche.startY = touches.clientY;
                    return;
                }
                if (modelEndTranY > modelHtmlHeight) {
                    if (modelEndY < modelHtmlHeight) {
                        modelEndY = modelHtmlHeight;
                    }
                    modelCss = {
                        "margin-top": modelEndY + "px",
                    };
                    $("#" + self.modelHtmlId).css(modelCss);
                    self.setTopOpacity(modelEndY, modelHtmlHeight);
                }
            } else {
                var messageScroll = this.scrollTop;
                if (messageScroll == 0) {
                    event.preventDefault();
                }else{
                    touche.startY = touches.clientY;
                    return;
                }
                if (endTranY == 0) {
                    if (modelEndY > 0) {
                        modelEndY = 0;
                    }
                    modelCss = {
                        "margin-top": modelEndY + "px",
                    };
                    $("#" + self.modelHtmlId).css(modelCss);
                    self.setTopOpacity(modelEndY, modelHtmlHeight);
                }
            }
            touche.startY = touches.clientY;
        });
    }
};*/
//店铺页面活动轮播效果
function transformScrolls(leftId, rightId, shop) {
    this.parameter(leftId, rightId, shop);
    this.init(leftId, rightId, shop);
}
transformScrolls.prototype = {
    parameter:function(leftId, rightId, shop){
        this.storeBody = $(".store_body");
        this.topMain = $(".top_main");
        this.modelHtml = $("#modelHtml");
        this.leftId = $(leftId);
        this.rightId = $(rightId);
        this.storeHtml = $(".store_html");
        this.storeContent = $("#storeContent");
        this.setLeft = true;
        this.TouchObj = {
            startY: 0,
            scrollY: 0
        };
        /*this.rightTouchObj = {
         startY: 0,
         scrollY: 0
         };*///初始化开始的位置和单位时间滚动距离
        this.bind();
        this.bind(this.leftId,this.TouchObj);
        this.bind(this.rightId,this.TouchObj);
        this.bind($("#message"),this.TouchObj);
    },
    init: function () {
        var _winHeight = $(window).height();
        var _height = _winHeight-80;
        this.storeBody.css({"height":_height+"px"});
        this.storeHtml.css({"height":_winHeight+"px"});
    },
    bind:function(bindId,TouchObj){
        var _self = this;
        if(bindId){
            bindId.bind("touchstart",function(e){
                _self.touchstart(this,TouchObj);
            });
            bindId.bind("touchmove",function(e){
                _self.touchmove(this,TouchObj);
            });
            bindId.bind("touchend",function(e){
                _self.touchend(this);
            });
        }
        else{
            this.topMain.bind("touchmove",function(e){
                e.preventDefault();
            });
            this.rightId.bind("scroll",function(e){
                _self.setLeftLiStyle(this);
            });
            this.LeftLi = $(this.leftId).find("li");
            if (document.querySelector('.store_tag_choose') == null) {
                this.LeftLi[0].setAttribute('class', 'store_tag_choose');
                this.lastClick = this.LeftLi[0];
            }
            var self = this;
            for (var i = 0; i < this.LeftLi.length; i++) {
                this.LeftLi[i].onclick = function () {
                    var id = this.id;
                    var leftLi = document.getElementById(id),rightUl = $(self.rightId);
                    var rightLiId = "goodList" + id.substring(8);
                    var rightLi = document.getElementById(rightLiId);
                    var scrollTop = rightLi.offsetTop-200;
                    self.setLeft = false;
                    rightUl.scrollTop(scrollTop);
                    self.lastClick.removeAttribute('class', 'store_tag_choose');
                    leftLi.setAttribute('class', 'store_tag_choose');
                    self.lastClick = leftLi;
                }
            }
            $(window).resize(function () {
                self.init();
            });
        }
    },
    getY: function (Id) {
        var _top = $("#" + Id).css("top");
        if (_top == "none") {
            _top = 0
        }
        else {
            _top = _top.substring(0,_top.length-2);
            _top = parseInt(_top, 10)
        }
        if (!_top) {
            _top = 0
        }
        return _top
    },
    touchstart:function(dom,id){
        id.startY = event.touches[0].clientY;  // 纵坐标
        event.stopPropagation();
    },
    touchmove:function(dom,id){
        event.stopPropagation();
        var contentTop = this.getY("storeContent");
        var topHeight = this.modelHtml.height();
        var dom_scroll_height = dom.scrollTop;
        var touches = event.touches[0];
        var endY = touches.clientY - id.startY;
        if (endY > 0) {
            //向下滑动;
            if(dom_scroll_height<=0){
                event.preventDefault();
            }
            if(id.scrollY==0){
                var new_top = contentTop+endY;
                if(new_top>=0){
                    new_top = 0;
                }
                this.setTopOpacity(new_top, topHeight-40);
                this.storeContent.css({
                    "position": "absolute",
                    "width": "100%",
                    "top": (new_top)+"px",
                })
            }
        }else{
            //向上滑动
            if(contentTop>40-topHeight){
                event.preventDefault();
                var new_top = contentTop+endY;
                if(new_top<=(40-topHeight)){
                    new_top = 40-topHeight;
                }
                this.setTopOpacity(new_top, topHeight-40);
                this.storeContent.css({
                    "position": "absolute",
                    "width": "100%",
                    "top": (new_top)+"px",
                })
            }
        }
        id.startY = touches.clientY;
        id.scrollY = dom_scroll_height
    },
    touchend:function(e,dom){
        //event.stopPropagation();
    },
    setTopOpacity: function (position, height) {
        var topHeadBac = document.getElementById('topHeadBac');
        topHeadBac.style.opacity = position / (-height);
    },
    setLeftLiStyle: function (dom) {
        var scrollTop = dom.scrollTop;
        var rightLi = $(this.rightId).find('.store_mainmenu ');
        var rightLiId, rightLiTop,leftLi,leftLiId;
        for (var i = 0; i < rightLi.length; i++) {
            rightLiTop = rightLi[i].offsetTop-200+rightLi[i].offsetHeight;
            if (rightLiTop > scrollTop) {
                rightLiId = rightLi[i].id;
                break;
            }
        }
        leftLiId = "leftList" + rightLiId.substring(8);
        if(this.setLeft){
            if (this.lastClick&&this.lastClick.id != leftLiId) {
                leftLi = document.getElementById(leftLiId);
                this.lastClick.removeAttribute('class', 'store_tag_choose');
                leftLi.setAttribute('class', 'store_tag_choose');
                this.lastClick = leftLi;
            }
        }else{
            this.setLeft = true;
        }
    }
};
//店铺页面活动轮播效果
function activeTextAnimation() {
    var self = this;
    this.activeList = document.getElementById('activeText').getElementsByTagName('p');
    this.now = 0;
    this.activeLength = this.activeList.length;
    this.init();
    setTimeout(function () {
        self.run();
    }, 5000);
}
activeTextAnimation.prototype = {
    init: function () {
        this.now = this.getNow(this.now);
        for (var i = 0; i < this.activeLength; i++) {
            if (i == this.now) {
                $(this.activeList[i]).css({position: "absolute",top: "30px", transition: "0ms"});
                $(this.activeList[i]).css({position: "absolute",top: "0", transition: "all 500ms ease"});
            }
            else {
                $(this.activeList[i]).css({position: "absolute",top: "-30px", transition: "all 500ms ease"});
                $(this.activeList[i]).css({position: "absolute",top: "30px", transition: "0ms"});
            }
        }
    },
    getNow: function (now) {
        return now % this.activeLength;
    },
    run: function () {
        var self = this;
        if (this.activeLength > 1) {
            setInterval(function () {
                self.now++;
                self.init();
            }, 5000)
        }
        ;
    }
};
//店铺公告走马灯效果
var a,b,c,d;
function announcement_run(fist) {
    var announcement = $(".announcement");
    if(announcement[0]==undefined){
        return;
    }
    if(fist){
        clearTimeout(a);
        clearTimeout(b);
        clearTimeout(c);
        clearTimeout(d);
    }
    var announcementWidth = announcement[0].offsetWidth;
    var context = announcement.find("span");
    var contextSpan1 = context[0];
    var contextSpan2 = context[1];
    var contextWidth = context[0].offsetWidth;
    if (contextWidth > announcementWidth) {
        var time1 = (contextWidth - announcementWidth) * 30;
        var time2 = contextWidth * 30;
        var time3 = announcementWidth * 30;
        var time4 = time2 + announcementWidth*30;
        var setCss = function(width,time){
            var contextCss = {
                left: width + "px",
                transition: "left " + time + "ms linear",
                WebkitAnimation: "left " + time + "ms linear"
            };
            return contextCss;
        };
        $(contextSpan1).css(setCss(-contextWidth,time2));
        $(contextSpan2).css(setCss(announcementWidth,0));
        a = setTimeout(function () {
            $(contextSpan2).css(setCss(-contextWidth,time4));
        }, time1);
        b = setTimeout(function () {
            $(contextSpan1).css(setCss(announcementWidth,0));
        }, time2);
        c = setTimeout(function () {
            $(contextSpan1).css(setCss(0,time3));
        }, time1+time2);
        d = setTimeout(function(){
            $(contextSpan2).css(setCss(announcementWidth,0));
            announcement_run(false);
        },time1+time4);
    }
}
